<?php
namespace app\admin\controller;
use think\Session;
class Manager extends Base
{
   public function login(){
       $id = Session::get('mg_id');
       if($id>0){
           $this->redirect('index/index');
       }
       if($_POST){
            $captcha = $_POST['captcha'];
            if(!captcha_check($captcha)){
                $this->error( "验证码错误!");   
        };
            $name = $_POST['name'];
            $password = $_POST['password'];
           $data = db('manager')->where('mg_name',$name)->where('mg_status',1)->find();
            if($data){
                if($data['mg_pwd'] == $password){
//                  $this->redirect('register'); 
                    session('mg_id',$data['mg_id']);
                    session('mg_name',$name);
                    $this->success('登录成功',"index/index");
                } else {
                $this->error( "密码错误!");   
                }
            }else{
                 $this->error( "账号不存在!");   
            }
        }else{
        return $this->fetch();
            
        }
    }
   
    public function logout(){
    Session::clear();
    $this->redirect('manager.login');    
    }
    
 public function managerList(){
       return $this->fetch();
   }
 public function add(){
       return $this->fetch();
   }    
 public function del(){
       return $this->fetch();
   }
 public function browse(){
       return $this->fetch();
   }   
 public function download(){
       return $this->fetch();
   }    
  public function share(){
       return $this->fetch();
   }   
  public function show(){
       return $this->fetch();
   }   
   
   
   
   
}
